<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>General SQL Parser C/C++ version: Getting Started</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">General SQL Parser C/C++ version
   
   </div>
   <div id="projectbrief">General SQL Parser C/C++ version</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="index.html">index</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Getting Started </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h4>Directories and files:</h4>
<ul>
<li>core: header files for core parser.</li>
<li>lib: library for core parser and collection<ul>
<li>gspcore.lib, core parser library for windows</li>
<li>libgspcore.a, core parser library for Linux</li>
<li>gspcollection.lib, extension library for windows<ul>
<li>you can build this library from the source code under ext/collection</li>
</ul>
</li>
<li>libgspcollection.a, core parser library for Linux<ul>
<li>you can build this library from the source code under ext/collection</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li>ext: source code for extensions of core parser including visitors and iterators.</li>
<li><a href="demos.html">demos</a>: demos demonstrate how to use this SQL Parser.</li>
</ul>
<h4>Write Programs That Use General SQL Parser(GSP)</h4>
<p>Below is a simple C program that demonstrates how to use the C/C++ interface to GSP.</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;stdio.h&gt;</span>
<span class="preprocessor">#include &quot;<a class="code" href="gsp__base_8h.html" title="Includes all basic data structures used by SQL Parser.">gsp_base.h</a>&quot;</span> 
<span class="preprocessor">#include &quot;<a class="code" href="gsp__sqlparser_8h.html" title="functions used to create/free an instance of sql parser.">gsp_sqlparser.h</a>&quot;</span>

<span class="keywordtype">int</span> main()
{
        <a class="code" href="structgsp__sqlparser.html">gsp_sqlparser</a> *parser;
        <span class="keywordtype">int</span> rc;
        <span class="keywordtype">char</span> *sql = 
                                <span class="stringliteral">&quot;SELECT last_name, \n&quot;</span>
                                <span class="stringliteral">&quot;       job_id, \n&quot;</span>
                                <span class="stringliteral">&quot;       salary \n&quot;</span>
                                <span class="stringliteral">&quot;FROM   employees \n&quot;</span>
                                <span class="stringliteral">&quot;WHERE  job_id = (SELECT job_id \n&quot;</span>
                                <span class="stringliteral">&quot;                 FROM   employees \n&quot;</span>
                                <span class="stringliteral">&quot;                 WHERE  employee_id = 141) \n&quot;</span>
                                <span class="stringliteral">&quot;       AND salary &gt; (SELECT salary \n&quot;</span>
                                <span class="stringliteral">&quot;                     FROM   employees \n&quot;</span>
                                <span class="stringliteral">&quot;                     WHERE  employee_id = 141);\n&quot;</span>
                                ;

        rc = <a class="code" href="gsp__sqlparser_8h.html#a7b285c36ca503c27fe57669c270a2fbb">gsp_parser_create</a>(<a class="code" href="gsp__base_8h.html#a5be3eb4b6f4ff089dbd3951ff1329e48a38bc3a06819fb5794c40c5973ee3b2f0">dbvoracle</a>,&amp;parser);
        <span class="keywordflow">if</span> (rc){
                fprintf(stderr,<span class="stringliteral">&quot;create parser error&quot;</span>);
                <span class="keywordflow">return</span> 1;
        }

        rc= <a class="code" href="gsp__sqlparser_8h.html#aca0bcbe8faf7160f9b88a9d6719668ea">gsp_check_syntax</a>(parser,sql);
        <span class="keywordflow">if</span> (rc != 0){
                fprintf(stderr,<span class="stringliteral">&quot;parser error:%s\n&quot;</span>,<a class="code" href="gsp__sqlparser_8h.html#a869bb4a79714a81bd47fa1313bc50994">gsp_errmsg</a>(parser));
        }<span class="keywordflow">else</span>{
                fprintf(stdout,<span class="stringliteral">&quot;parser ok\n&quot;</span>);
        }

        <a class="code" href="gsp__sqlparser_8h.html#a8ba5e924e9494957794fc6b81522cb92">gsp_parser_free</a>(parser);

        <span class="keywordflow">return</span> 0;
}
</pre></div><h4>compile this simple C program under windows using Visual C</h4>
<p>Set environment for using Microsoft Visual Studio 2008 x86 tools by running: </p>
<div class="fragment"><pre class="fragment">C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat</pre></div><p> then, generate first.exe by running: </p>
<div class="fragment"><pre class="fragment">cl first.c  /I ../core /link ../lib/gspcore.lib</pre></div> <h4>compile this simple C program under Linux using gcc</h4>
<div class="fragment"><pre class="fragment">gcc -O2 first.c -I../core -L../lib -lgspcore -o first</pre></div> </div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Mon Oct 3 2016 11:30:04 for General SQL Parser C/C++ version by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
